{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="btn-group">
                            <!--<a><button id='bt-add' type="button" class="btn btn-primary">增加</button></a>-->
                            <!--<a><button id='bt-del' data-text="确定删除主机? 0个" type="button" class="btn btn-danger">删除</button></a>-->
                            <a>
                                <button id='bt-search' type="button" class="btn btn-success">高级搜索</button>
                            </a>
                            <a>
                                <button id='bt-reset' type="button" class="btn btn-danger">重置高级搜索</button>
                            </a>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div id="div-search" class="hide">
                            <table id="high-search" style="width: 67%; margin: 0 auto 2em auto;" border="0"
                                   cellpadding="3" cellspacing="0">
                                <thead>
                                <tr>
                                    <th>目标</th>
                                    <th>内容</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr id="_filter_company" data-column="5">
                                    <td>公司</td>
                                    <td align="center">
                                        <select id="filter_company" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for company in all_company %}
                                                <option value={{ company.id }}>{{ company.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_CPU" data-column="6">
                                    <td>CPU</td>
                                    <td align="center">
                                        <select id="filter_CPU" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for cpu in all_cpu %}
                                                <option value={{ cpu }}>{{ cpu }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_board" data-column="6">
                                    <td>主板</td>
                                    <td align="center">
                                        <select id="filter_board" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for board in all_board %}
                                                <option value={{ board }}>{{ board }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_ssd" data-column="6">
                                    <td>固态硬盘</td>
                                    <td align="center">
                                        <select id="filter_ssd" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for ssd in all_ssd %}
                                                <option value={{ ssd }}>{{ ssd }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_disk" data-column="6">
                                    <td>机械硬盘</td>
                                    <td align="center">
                                        <select id="filter_disk" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for disk in all_disk %}
                                                <option value={{ disk }}>{{ disk }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_mem" data-column="6">
                                    <td>内存</td>
                                    <td align="center">
                                        <select id="filter_mem" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for mem in all_mem %}
                                                <option value={{ mem }}>{{ mem }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_graphics" data-column="6">
                                    <td>显卡</td>
                                    <td align="center">
                                        <select id="filter_graphics" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for graphics in all_graphics %}
                                                <option value={{ graphics }}>{{ graphics }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_status" data-column="2">
                                    <td>状态</td>
                                    <td align="center">
                                        <select id="filter_status" style="width: 100%">
                                            <option value="100" selected="selected">全部</option>
                                            <option value="0">库存</option>
                                            <option value="1">领用</option>
                                            <option value="2">外借</option>
                                            <option value="3">回收</option>
                                            <option value="4">损毁</option>
                                            <option value="5">清理</option>
                                            <option value="6">变卖</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_number" data-column="5">
                                    <td>数量</td>
                                    <td align="center"><input style="width:100%" class="column_filter"
                                                              id="filter_number" type="text"></td>
                                </tr>
                                <tr id="_filter_pos" data-column="2">
                                    <td>位置</td>
                                    <td align="center">
                                        <select id="filter_pos" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr id="_filter_user" data-column="6">
                                    <td>领用人</td>
                                    <td align="center">
                                        <select id="filter_user" class="filter_select2" style="width: 100%">
                                            <option value="0" selected="selected">全部</option>
                                            {% for user in all_users %}
                                                <option value={{ user.text }}>{{ user.text }}</option>
                                            {% endfor %}
                                        </select>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <!-- 统计 -->

                        <div class="row">
                            <div class="col-lg-12">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        数量汇总
                                    </div>
                                    <!-- .panel-heading -->
                                    <div class="panel-body">
                                        <div class="panel-group" id="accordion">
                                            {% for x in ctype_count %}
                                                <div class="panel panel-default">
                                                    <div class="panel-heading">
                                                        <h4 class="panel-title">
                                                            <a data-toggle="collapse" data-parent="#accordion"
                                                               href="#collapse{{ forloop.counter }}">{{ x.part_model__ctype }}: {{ x.total }}</a>
                                                        </h4>
                                                    </div>
                                                    <div id="collapse{{ forloop.counter }}"
                                                         class="panel-collapse collapse">
                                                        <div class="panel-body">
                                                            {% if x.part_model__ctype == '内存' %}
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in mem_brand_count %}
                                                                        {% if not x.part_model__brand %}
                                                                            无：
                                                                        {% else %}
                                                                            {{ x.part_model__brand }}：
                                                                        {% endif %}
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按型号统计</b><br/>
                                                                    {% for x in mem_smodel_count %}
                                                                        {{ x.part_model__smodel }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按公司统计</b><br/>
                                                                    {% for x in mem_company_count %}
                                                                        {{ x.part_model__company__name }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                            {% endif %}
                                                            {% if x.part_model__ctype == '机械硬盘' %}
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in hdd_brand_count %}
                                                                        {{ x.part_model__brand }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按型号统计</b><br/>
                                                                    {% for x in hdd_smodel_count %}
                                                                        {{ x.part_model__smodel }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按公司统计</b><br/>
                                                                    {% for x in hdd_company_count %}
                                                                        {{ x.part_model__company__name }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                            {% endif %}
                                                            {% if x.part_model__ctype == '固态硬盘' %}
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in ssd_brand_count %}
                                                                        {{ x.part_model__brand }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按型号统计</b><br/>
                                                                    {% for x in ssd_smodel_count %}
                                                                        {{ x.part_model__smodel }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按公司统计</b><br/>
                                                                    {% for x in ssd_company_count %}
                                                                        {{ x.part_model__company__name }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                            {% endif %}
                                                            {% if x.part_model__ctype == 'CPU' %}
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in cpu_brand_count %}
                                                                        {{ x.part_model__brand }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按公司统计</b><br/>
                                                                    {% for x in cpu_company_count %}
                                                                        {{ x.part_model__company__name }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                            {% endif %}
                                                            {% if x.part_model__ctype == '显卡' %}
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in graphics_brand_count %}
                                                                        {{ x.part_model__brand }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                                <p>
                                                                    <b>按品牌统计</b><br/>
                                                                    {% for x in graphics_company_count %}
                                                                        {{ x.part_model__company__name }}：
                                                                        {{ x.total }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                                        &nbsp;
                                                                    {% endfor %}
                                                                </p>
                                                            {% endif %}
                                                        </div>
                                                    </div>
                                                </div>
                                            {% endfor %}
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <table id="mytable" class="display" width="100%" cellspacing="0">
                            <thead>
                            <tr>
                                <th>id</th>
                                <th>所属公司</th>
                                <th>类型</th>
                                <th>品牌</th>
                                <th>型号</th>
                                <th>状态</th>
                                <th>数量</th>
                                <th>位置</th>
                                <th>供应商</th>
                                <th>保管人</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
            <!-- Modal -->
            <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel"></h4>
                        </div>
                        <div class="modal-body">
                            <div class="alert alert-danger alert-dismissable" id='modal-notify'>
                                <button type="button" class="close" id="bt-modal-notify">&times;</button>
                                <label id='lb-msg'></label>
                            </div>
                            <form class="form-horizontal" role="form">
                                <div class="form-group" id='show_id'>
                                    <label class="col-sm-3 control-label">主机id</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control " placeholder="" id="id">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">状态标识</label>
                                    <div class="col-sm-8">
                                        <select id="status">
                                            <option value="0">未初始化</option>
                                            <option value="1" selected="selected">可用</option>
                                            <option value="2">停用</option>
                                            <option value="3">新机器</option>
                                            <option value="4">已归还</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">机器归属</label>
                                    <div class="col-sm-8">
                                        <select id="host_class">
                                            <option value="0" selected="selected">公司内网</option>
                                            <option value="1">公司自有外网机器</option>
                                            <option value="2">游戏合作商提供</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">所在项目</label>
                                    <div class="col-sm-8">
                                        <select id="belongs_to_game_project" style="width: 100%">
                                            <option selected="selected" value="0">选择项目</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">所在机房</label>
                                    <div class="col-sm-8">
                                        <select id="belongs_to_room" style="width: 100%">
                                            <option selected="selected" value="0">选择机房</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">机器类型</label>
                                    <div class="col-sm-8">
                                        <select id="machine_type">
                                            <option value="0" selected="selected">云主机</option>
                                            <option value="1">物理机</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">业务类型</label>
                                    <div class="col-sm-8">
                                        <select id="belongs_to_business" style="width: 100%">
                                            <option selected="selected" value="0">选择业务类型</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">平台或提供商标识</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="YY" id="platform">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">局域网IP</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="192.168.1.1"
                                               id="internal_ip">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">电信ip</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="43.18.12.132"
                                               id="telecom_ip">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">联通ip</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="43.18.12.132"
                                               id="unicom_ip">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">操作系统</label>
                                    <div class="col-sm-8">
                                        <select id="system">
                                            <option value="0" selected="selected">linux</option>
                                            <option value="1">windows</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label ">公网访问状态标识</label>
                                    <div class="col-sm-8">
                                        <select id="is_internet">
                                            <option value="0" selected="selected">完全内网机器</option>
                                            <option value="1">公网访问不了但可上外网</option>
                                            <option value="2">公网可访问</option>
                                            <option value="3">映射外部受限访问</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">服务器SSH用户</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="sshuser">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">服务器SSH端口</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="sshport">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">机器型号</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="machine_model">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">cpu核心数</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="cpu_num">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">cpu</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="cpu">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">ram</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="ram">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">硬盘</label>
                                    <div class="col-sm-8">
                                        <div class="form-group row">
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control " id="disk">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">用途</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="host_comment">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">宿主机</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="belongs_to_host">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">标识符</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" placeholder="" id="host_identifier">
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            <button id='bt-save' type="button" class="btn btn-primary">保存</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div><!-- /.modal -->
            <div class="modal fade" id="Modal-file" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <form id="submit-file-form" enctype="multipart/form-data" action="/assets/upload_devices"
                              method="post">
                            <!-- {% csrf_token %} -->
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">导入/导出</h4>
                            </div>
                            <div class="modal-body">
                                <div class="alert alert-dismissable" id='upload-notify'>
                                    <button type="button" class="close" id="bt-upload-notify">&times;</button>
                                    <label id='lb-msg-upload'></label>
                                </div>

                                <div class="form-group">
                                    {{ form }}
                                    <p class="help-block">Example block-level help text here.</p>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary" name='action'>保存</button>
                            </div>
                        </form>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>
        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/jquery.dataTables.js"></script>
    {{ django_context_varable }}
    {% verbatim %}
    <script id="tpl" type="text/x-handlebars-template">
        {{#each func}}
        <button type="button" class="btn btn-{{this.type}} btn-sm" onclick="{{this.fn}}">{{this.name}}</button>
        {{/each}}
    </script>
    {% endverbatim %}
    <script src="/static/js/handlebars-v3.0.1.js"></script>
    <script src="/static/js/sub_assets_reception.js?v=20190529001"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/jquery.dataTables.css" rel="stylesheet" type="text/css">
    <link href="/static/css/mycss.css" rel="stylesheet" type="text/css">
{% endblock %}
